import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @author: zlz
 * @date: 2021/9/12 21:58
 * @description:
 * @since: JDK1.8
 */
public class FileChanelDemo {
    public static void main(String[] args) throws Exception {
        FileOutputStream outputStream = new FileOutputStream("D://zlz.txt");
        FileChannel channel = outputStream.getChannel();
        ByteBuffer buffer = ByteBuffer.allocate(1024);
        String msg = "hell,曾令忠";
        buffer.put(msg.getBytes());
        buffer.flip();
        channel.write(buffer);
        outputStream.close();
    }
}
